package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.Storage;
import com.cskaoyan.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * Description
 * 小程序存储照片
 *
 * @author Zhangfei
 * @date Created on 2021/10/21
 */
@RestController
@RequestMapping("/wx/storage")
public class WXStorageController {

    @Autowired
    StorageService storageService;

    /**
     * 图片上传功能
     *
     * @param req
     * @param file
     * @return
     */
    @PostMapping("/upload")
    public BaseRespVo upload(HttpServletRequest req, MultipartFile file) {
        Storage storage = storageService.create(req, file);
        return BaseRespVo.ok(storage);
    }


}
